using System;
using System.Data.SQLite;

namespace LoggingLibrary
{
    public class DatabaseLogger : ILogger
    {
        private readonly string _connectionString;

        public DatabaseLogger(string connectionString)
        {
            _connectionString = connectionString;
        }

        public void Log(string message)
        {
            using (var connection = new SQLiteConnection(_connectionString))
            {
                connection.Open();
                var command = connection.CreateCommand();
                command.CommandText = "INSERT INTO Logs (Message, Timestamp) VALUES (@message, @timestamp)";
                command.Parameters.AddWithValue("@message", message);
                command.Parameters.AddWithValue("@timestamp", DateTime.Now);
                command.ExecuteNonQuery();
            }
        }
    }
}